﻿using App_Clinique.ClassLibrary.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace App_Clinique
{
    public partial class MedicamentForm : Form
    {
        public MedicamentForm()
        {
            InitializeComponent();
        }

        /****************************************************************************************************
         * Methods
         ***************************************************************************************************/
        private void InitializeReferentielMedicamentsDataGridView()
        {
            try
            {
                ReferentielMedicamentsDataGridView.AutoGenerateColumns = false;
                ReferentielMedicamentsDataGridView.DataSource = Singleton.Current.Medicaments.OrderBy(m => m.Categorie).ThenBy(m => m.Nom).ToList();

                ReferentielMedicamentsDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
                ReferentielMedicamentsDataGridView.BorderStyle = BorderStyle.Fixed3D;

                ReferentielMedicamentsDataGridView.Show();
            }
            catch (InvalidCastException e)
            {
                MessageBox.Show(e.Message);
            }
        }

        /****************************************************************************************************
         * Events
         ***************************************************************************************************/
        private void MedicamentForm_Load(object sender, EventArgs e)
        {
            InitializeReferentielMedicamentsDataGridView();
        }
    }
}
